import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import _ from "lodash";
import uView from './uni_modules/vk-uview-ui';

import {
	router,
	RouterMount
} from './routes'
import store from "./store";

import Videojs from '!video.js' // 一定要加!
import 'video.js/dist/video-js.css'
Vue.prototype.$video = Videojs


Vue.use(router)
Vue.use(uView);


import Share from 'vue-social-share'

import 'vue-social-share/dist/client.css';

import 'node_modules/social-share.js/dist/js/social-share.min.js'

Vue.use(Share)

Vue.prototype.$navi = (routeLocation) => {
	if (typeof routeLocation == "string") {
		router.push(routeLocation);
	} else {
		const {
			route,
			isTab = false,
			type = 1,
			appid = ""
		} = routeLocation;
		if (type == 2) {
			uni.navigateToMiniProgram({
				appId: appid, // 跳转目标小程序的id
				path: route.path, // 目标小程序的页面路径
				success(res) {
					// 打开成功
				},
				fail() {
					// uni.showToast({
					//   title: '暂时无法打开',
					//   icon: "none",
					// });
				},
			});
		} else {
			if (!isTab) {
				// router.push(route);
				let routes = getCurrentPages()
				if (routes.length >= 8) {
					router.replaceAll(route)
				} else {
					router.push(route)
				}

			} else {
				if (type == 1) {
					router.pushTab(route);
					store.commit("ChangeName", route.name);
				}
			}
		}
	}
};

Vue.prototype.$Toast = (title, icon = "none") => {
	uni.showToast({
		title: title,
		icon: icon,
		mask: true,
	});
};
Vue.prototype.$Errback = (title, icon = "none") => {
	uni.showToast({
		title: title,
		icon: icon,
		mask: true,
	});
	setTimeout(() => {
		uni.navigateBack(-1);
	}, 1200)
};
Vue.prototype.$ClearLogin = (title) => {
	uni.showLoading({
		title: title,
		mask: true,
	});
	uni.removeStorageSync("uid");
	uni.removeStorageSync("userToken");
	uni.removeStorageSync("ident")
	uni.removeStorageSync("islogin")
	uni.removeStorageSync("name")
	uni.removeStorageSync("tabIndex")
	uni.removeStorageSync('caseid')
	uni.removeStorageSync("fileDir")
	setTimeout(() => {
		uni.navigateTo({
			url: "/pages/index/index"
		})
	}, 1200)
};
Vue.prototype.$Loading = (title = "", mask = true) => {
	uni.showLoading({
		title: title,
		mask: mask,
	});
};
Vue.prototype.$goTop = ()=>{
	uni.pageScrollTo({
		scrollTop: 0,
		duration: 100,
	});
}
Vue.prototype._ = _;



Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	store,
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif